home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 540 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: mail2news.demon.co.uk!oxas.demon.co.uk
  2. From: "Michael R. Mayer" <mmayer@oxas.demon.co.uk>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Translate C++ to C
  5. Date: Thu, 04 Jan 1996 23:25:26 +0100
  6. Organization: None now!
  7. Message-ID: <103996057wnr@oxas.demon.co.uk>
  8. References: <4ce768$5iu@news.uit.no>
  9. Reply-To: mmayer@oxas.demon.co.uk
  10. X-NNTP-Posting-Host: oxas.demon.co.uk
  11. X-Newsreader: Newswin Alpha 0.9
  12. X-Mail2News-Path: relay-4.mail.demon.net!post.demon.co.uk!oxas.demon.co.uk
  13.  
  14. Oh, good another student...
  15.  
  16. Rather than just throw rocks here are a few pointers...
  17.  
  18.  
  19.  
  20. In article: <4ce768$5iu@news.uit.no>  odu@stud.cs.uit.no (O.O) writes:
  21. > Could C/C++ gurus translate the following  C++ to C.
  22. > 1)    Comp ->set(Ts :: execute, flow ->GetId(), 
  23. >                  Ts :: abs, x);
  24.  
  25. -> (the arrow operator) is used to access members when you only have a    
  26.    pointer to an instance. Thus Comp is presumably a pointer to an
  27.    instance (class unknown). Thus in 1 the method (member function)
  28.    set() is being called (N.B. there may be more than one set() method)
  29.  
  30. :: In the case of 1 this is probably the class scope resolution
  31.    operator. I would GUESS that execute & abs are methods of the
  32.    class Ts. 
  33.  
  34. >                  
  35. > 2)    Ts  *kflow = new Ts(2);                          
  36.  
  37. The new operator is like malloc() only MUCH better since there is no 
  38. need to do casting and it is more flexible due to constructors for 
  39. starters. The new operator creates an new instance of a class. It 
  40. returns a pointer to the instance. As part of the process it calls the 
  41. class constructor. In this case the constructor is being passed an 
  42. argument '2'.
  43.  
  44. I suggest that you try reading at least one C++ primer before you try to   
  45. understand what this code is doing. Please do some work in future before  
  46. asking others.
  47.  
  48. -- 
  49. Michael
  50.  
  51. (load '/users/mmayer/standard_disclaimer.lsp)
  52. ------------------------------------------------------
  53. " 'cause we don't know where we come from.
  54.                 We don't know what we are."
  55.  
  56.